<template>
  <el-row :gutter="40" class="panel-group">
    
    <el-col :xs="12" :sm="12" :lg="1" class="card-panel-col">
    </el-col>

    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel-big">
        <div class="card-panel-icon-wrapper icon-bule">
          <svg-icon icon-class="build" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            资源总量
          </div>
          <count-to :start-val="0" :end-val="total.article+total.multimodal" :duration="2600" class="card-panel-num" />
        </div>
      </div>
    </el-col>

    <!-- <el-col :xs="12" :sm="12" :lg="8" class="card-panel-col">
      <div class="card-panel-big">
        <div class="card-panel-icon-wrapper icon-bule">
          <svg-icon icon-class="cascader" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            科普图文总量
          </div>
          <count-to :start-val="0" :end-val="total.article" :duration="3000" class="card-panel-num" />
        </div>
      </div>
    </el-col> -->

    <!-- <el-col :xs="12" :sm="12" :lg="8" class="card-panel-col">
      <div class="card-panel-big">
        <div class="card-panel-icon-wrapper icon-bule">
          <svg-icon icon-class="command" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            多模态总量
          </div>
          <count-to :start-val="0" :end-val="total.multimodal" :duration="3200" class="card-panel-num" />
        </div>
      </div>
    </el-col> -->

    <el-col :xs="12" :sm="12" :lg="8" class="card-panel-col">
      <div class="card-panel">
        <div class="card-panel-icon-wrapper icon-green">
          <svg-icon icon-class="card-image" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            科普图片数量
          </div>
        </div>
        <div class="card-panel-description">
          <count-to :start-val="0" :end-val="total.multimodal_image" :duration="3600" class="card-panel-num" />
        </div>
      </div>
    </el-col>

    <el-col :xs="12" :sm="12" :lg="8" class="card-panel-col">
      <div class="card-panel">
        <div class="card-panel-icon-wrapper icon-green">
          <svg-icon icon-class="camera-reels" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            科普视频数量
          </div>
        </div>
        <div class="card-panel-description">
          <count-to :start-val="0" :end-val="total.multimodal_video" :duration="3600" class="card-panel-num" />
        </div>
      </div>
    </el-col>

    <el-col :xs="12" :sm="12" :lg="8" class="card-panel-col">
      <div class="card-panel">
        <div class="card-panel-icon-wrapper icon-green">
          <svg-icon icon-class="camera-video" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            科普音频数量
          </div>
        </div>
        <div class="card-panel-description">
          <count-to :start-val="0" :end-val="total.multimodal_audio" :duration="3600" class="card-panel-num" />
        </div>
      </div>
    </el-col>
    
    <el-col :xs="12" :sm="12" :lg="8" class="card-panel-col">
      <div class="card-panel">
        <div class="card-panel-icon-wrapper icon-green">
          <svg-icon icon-class="documentation" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            科普文本数量
          </div>
        </div>
        <div class="card-panel-description">
          <count-to :start-val="0" :end-val="total.article+total.multimodal_text" :duration="3600" class="card-panel-num" />
        </div>
      </div>
    </el-col>
  </el-row>
</template>

<script>
import CountTo from 'vue-count-to'
import { mapGetters } from 'vuex'
import { listBizDailyGrowth } from "@/api/information/bizDailyGrowth/"
import bus from '@/views/dashboard/bus'

export default {
  components: {
    CountTo,
    ...mapGetters([
      'total'
    ]),
  },
  data(){
    return {
      queryParams: {
        multimodal: 0,
        multimodal_image: 0,
        multimodal_video: 0,
        multimodal_audio: 0,
        multimodal_text: 0,
        article: 0
      },
      total: {
        multimodal: 0,
        multimodal_image: 0,
        multimodal_video: 0,
        multimodal_audio: 0,
        multimodal_text: 0,
        article: 0
      },
      rows: []
    };
  },
  methods: {
    fetchlistBizDailyGrowth() {
      listBizDailyGrowth(this.queryParams).then(response => {
        this.rows = response
        const sum = response.reduce((accumulator, currentValue) => {
          return {
            multimodal: accumulator.multimodal + currentValue.multimodal,
            multimodal_image: accumulator.multimodal_image + currentValue.multimodal_image,
            multimodal_video: accumulator.multimodal_video + currentValue.multimodal_video,
            multimodal_audio: accumulator.multimodal_audio + currentValue.multimodal_audio,
            multimodal_text: accumulator.multimodal_text + currentValue.multimodal_text,
            article: accumulator.article + currentValue.article
          };
        }, {
          multimodal: 0,
          multimodal_image: 0,
          multimodal_video: 0,
          multimodal_audio: 0,
          multimodal_text: 0,
          article: 0
        });

        this.total = sum;
        bus.$emit('pieData',this.total)
        bus.$emit('lineData',this.rows)
      });
    }
  },
  created(){
    this.fetchlistBizDailyGrowth();
  }
}
</script>

<style lang="scss" scoped>
.panel-group {
  margin-top: 0px;

  .card-panel-col {
    margin-bottom: 24px;
  }

  .card-panel-big{
    height: 241px;
    cursor: pointer;
    font-size: 24px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
    border-color: rgba(0, 0, 0, .05);

    &:hover {
      .card-panel-icon-wrapper {
        color: #fff;
      }

      .icon-bule {
        background: #36a3f7;
      }
    }

    .icon-bule {
      color: #36a3f7;
    }

    .card-panel-icon-wrapper {
      display:flex;
      justify-content:center;/*主轴上居中*/
      align-items:center;/*侧轴上居中*/
      margin: 14px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
      margin-bottom: 16px;
    }

    .card-panel-icon {
      float: center;
      font-size: 120px;
    }

    .card-panel-description {
      font-weight: bold;
      // padding-right: 60px;

      .card-panel-text {
        display:flex;
        justify-content:center;/*主轴上居中*/
        align-items:center;/*侧轴上居中*/
        line-height: 18px;
        color: rgba(0, 0, 0, 0.45);
        font-size: 22px;
        margin-bottom: 12px;
      }

      .card-panel-num {
        display:flex;
        justify-content:center;/*主轴上居中*/
        align-items:center;/*侧轴上居中*/
        font-size: 20px;
      }
    }
  }

  .card-panel {
    padding-left: 20px;
    height: 108px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
    border-color: rgba(0, 0, 0, .05);

    &:hover {
      .card-panel-icon-wrapper {
        color: #fff;
      }

      // .icon-message {
      //   background: #36a3f7;
      // }

      // .icon-money {
      //   background: #f4516c;
      // }

      .icon-green {
        background: #34bfa3
      }
    }

    // .icon-message {
    //   color: #36a3f7;
    // }

    // .icon-money {
    //   color: #f4516c;
    // }

    .icon-green {
      color: #34bfa3
    }

    .card-panel-icon-wrapper {
      float: left;
      margin: 14px 0 0 14px;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }

    .card-panel-icon {
      float: left;
      font-size: 60px;
    }

    .card-panel-description {
      display:flex;
      justify-content:center;/*主轴上居中*/
      align-items:center;/*侧轴上居中*/
      // float: right;
      font-weight: bold;
      margin: 26px;
      margin-left: 0px;

      .card-panel-text {
        line-height: 18px;
        color: rgba(0, 0, 0, 0.45);
        font-size: 20px;
        // margin-bottom: 12px;
      }

      .card-panel-num {
        font-size: 20px;
      }
    }
  }
}

@media (max-width:550px) {
  .card-panel-description {
    display: none;
  }

  .card-panel-icon-wrapper {
    float: none !important;
    width: 100%;
    height: 100%;
    margin: 0 !important;

    .svg-icon {
      display: block;
      margin: 14px auto !important;
      float: none !important;
    }
  }
}
</style>
